/**
 * 
 */
package game;

import java.awt.Image;

import javax.swing.ImageIcon;

/**
 * @author patrick
 *
 */
public class Switch extends Sprite{

	private boolean on;
	private String onImage;
	private boolean hasBeenSwitched; 
	
	
	/**
	 * @param offImage path to DEFAULT image
	 * @param pOnImage path to alternate image
	 * */
	public Switch(String offImage, String pOnImage) {
		super(offImage);
		this.defaultImage = offImage;
		this.on = false;
		this.onImage = pOnImage;
		
		this.hasBeenSwitched = false;
	}
	
	/**
	 * @param offImage path to DEFAULT image
	 * @param pOnImage path to alternate image
	 * */
	public Switch(String offImage, String pOnImage, int xPosition, int yPosition) {
		super(offImage);
		this.defaultImage = offImage;
		this.on = false;
		this.onImage = pOnImage;
		this.x = xPosition;
		this.y = yPosition;
	}
	
	/**
	 * Turn the switch ON, and change the image to onImage
	 * */
	public void switchON (){
		this.on = true;
		ImageIcon ii = new ImageIcon(this.getClass().getResource(onImage));
		this.image = ii.getImage();
		width = image.getWidth(null);
		height = image.getHeight(null);
	}
	
	/**
	 * Turn the switch OFF (default position), and change the image to default
	 * */
	public void switchOFF(){
		this.on = false;
		this.on = true;
		
		ImageIcon ii = new ImageIcon(this.getClass().getResource(defaultImage));
		this.image = ii.getImage();
		width = image.getWidth(null);
		height = image.getHeight(null);
	}

	/**
	 * @return is switch on or off
	 */
	public boolean isOn() {
		return on;
	}

	/**
	 * @param on the on to set
	 */
	public void setOn(boolean on) {
		this.on = on;
	}

	/**
	 * @return the hasBeenSwitched
	 */
	public boolean hasBeenSwitched() {
		return hasBeenSwitched;
	}

	/**
	 * @param hasBeenSwitched the hasBeenSwitched to set
	 */
	public void setHasBeenSwitched(boolean hasBeenSwitched) {
		this.hasBeenSwitched = hasBeenSwitched;
	}

}
